//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.tuliu.appupdate.crash;

import android.text.TextUtils;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

class Md5Utils {
    private static final char[] HEX = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
    private static final char[] HEX_LOWER_CASE = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
    public static final String ALGORITHM = "MD5";
    public static final String DEFAULT_CHARSET = "UTF-8";

    Md5Utils() {
    }

    static String md5(String string) {
        try {
            MessageDigest e = MessageDigest.getInstance("MD5");
            byte[] buffer = string.getBytes("UTF-8");
            e.update(buffer);
            buffer = e.digest();
            string = toHex(buffer);
        } catch (NoSuchAlgorithmException var3) {
            ;
        } catch (UnsupportedEncodingException var4) {
            ;
        } catch (Exception var5) {
            ;
        }

        return string;
    }

    private static String toHex(byte[] b) {
        StringBuilder builder = new StringBuilder();
        byte[] arr$ = b;
        int len$ = b.length;

        for(int i$ = 0; i$ < len$; ++i$) {
            byte v = arr$[i$];
            builder.append(HEX[(240 & v) >> 4]);
            builder.append(HEX[15 & v]);
        }

        return builder.toString();
    }

    static String md5LowerCase(String string) {
        if(TextUtils.isEmpty(string)) {
            return "";
        } else {
            try {
                MessageDigest e = MessageDigest.getInstance("MD5");
                byte[] buffer = string.getBytes("UTF-8");
                e.update(buffer);
                buffer = e.digest();
                string = toLowerCaseHex(buffer);
            } catch (NoSuchAlgorithmException var3) {
                ;
            } catch (UnsupportedEncodingException var4) {
                ;
            } catch (Exception var5) {
                ;
            }

            return string;
        }
    }

    private static String toLowerCaseHex(byte[] b) {
        StringBuilder builder = new StringBuilder();
        byte[] arr$ = b;
        int len$ = b.length;

        for(int i$ = 0; i$ < len$; ++i$) {
            byte v = arr$[i$];
            builder.append(HEX_LOWER_CASE[(240 & v) >> 4]);
            builder.append(HEX_LOWER_CASE[15 & v]);
        }

        return builder.toString();
    }
}
